# Contributor: Justin Berthault <justin.berthault@zaclys.net>
# Contributor: Antoni Aloy <aaloytorrens@gmail.com>
# Maintainer: Justin Berthault <justin.berthault@zaclys.net>
pkgname=musescore
pkgver=4.1.0
pkgrel=2
pkgdesc="Create, play and print beautiful sheet music"
url="https://musescore.org/"
# armhf blocked by qt5-qtdeclarative
# s390x and riscv64 blocked by luatex -> texlive
arch="all !armhf !s390x !riscv64"
license="GPL-3.0-only"
depends="
	kirigami-addons
	qt5-qtgraphicaleffects
	qt5-qtquickcontrols
	qt5-qtquickcontrols2
	sonnet5
	"
makedepends="
	clang
	cmake
	doxygen
	jack-dev
	lame-dev
	libopusenc-dev
	libsndfile-dev
	poppler-qt5-dev
	portaudio-dev
	portmidi-dev
	pulseaudio-dev
	qt5-qtbase-dev
	qt5-qtdeclarative-dev
	qt5-qtlocation-dev
	qt5-qtnetworkauth-dev
	qt5-qtquickcontrols2-dev
	qt5-qtscript-dev
	qt5-qtsvg-dev
	qt5-qttools-dev
	qt5-qtwebchannel-dev
	qt5-qtx11extras-dev
	qt5-qtxmlpatterns-dev
	samurai
	"
subpackages="$pkgname-doc $pkgname-lang"
source="$pkgname-$pkgver.tar.gz::https://github.com/musescore/MuseScore/archive/v$pkgver.tar.gz
	no-kdock.patch
	no-update-check.patch
	system-libs.patch
	"
builddir="$srcdir"/MuseScore-$pkgver
options="!check" # todo

build() {
	PATH="$PATH:/usr/lib/qt5/bin" \
	CC=clang \
	CXX=clang++ \
	CFLAGS="${CFLAGS/-fstack-clash-protection} -O2 -DNDEBUG" \
	CXXFLAGS="${CXXFLAGS/-fstack-clash-protection} -O2 -DNDEBUG -D_LARGEFILE64_SOURCE" \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_SKIP_RPATH=ON \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DMUSESCORE_BUILD_CONFIGURATION=app \
		-DMUSESCORE_BUILD_MODE=release \
		-DMUE_BUILD_CRASHPAD_CLIENT=OFF \
		-DMUE_BUILD_UNIT_TESTS="$(want_check && echo ON || echo OFF)" \
		-DMUE_DOWNLOAD_SOUNDFONT=OFF
	cmake --build build --target all lrelease
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

lang() {
	pkgdesc="Translations for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel lang"

	amove usr/share/mscore-*/locale
}

sha512sums="
0dceb70d242afdd06ca47a6f9424e3f632fd4a9180e85a2a55884e7330896096cf07a8c76f554a80dd35aaa08b013fcda9b2098c98c9a3c2a8db431793bc9220  musescore-4.1.0.tar.gz
7be484541a5ada15b2cf47f9107d831964fe9b7ee40b9bb294b74ba1d33366ba8931be3eebfe1829dc170854d05728782090e0a7347b5b21351840df7651a0b4  no-kdock.patch
e1093ccf430d159ee4b2ef6a90615d635cba5c8977a59f7fc7b9bf72d8c7269d160fc328aa80b7c9f59c47bc43e925f016018d99b3c299d651d2076d782d5d12  no-update-check.patch
fe48cd833ffa3d9f870a07d7f2c9b80f5b3c937db4344915f381b40335f4e950f3d0ebf21866794fa9f23c658e0675bfa2c09a067c512055a6d06a653717e9eb  system-libs.patch
"
